home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
rlib
/
rank.r
< prev
next >
Wrap
Text File
|
1994-09-21
|
627b
|
27 lines
//-------------------------------------------------------------------//
//
// Syntax: rank ( A )
// rank ( A , tol )
// Description:
// Compute the rank of the matrix A. Rank returns the number of
// singular values that are larger than max( size(x) ) * norm(x,"2")
// * eps.
// If the user specifies tol, the the number of singular values
// larger than tol is returned.
//-------------------------------------------------------------------//
rank = function(x, tol)
{
local(s);
s = svd(x);
if (!exist (tol))
{
tol = max(size(x)) * norm(x,"2") * epsilon();
}
return sum(s.sigma > tol);
};